
// var Vm_index=new Vue({
//     el:'.index',
//     data:{index:"1111",sys_icon:'',platform_name:''},
//     methods: {
//         index_ajax: function (data) {
//             var _self=this;
//             console.log(url_operate+'sys/company')
//             $.ajax({
//                 url: url_operate+'sys/company',
//                 dataType: "json",type:'get',data:{"pageSize":10,"pageNum" :0,"code":null,
//                     "letterState":null,"sendType":null},
//                 xhrFields: {
//                     withCredentials: true
//                 }, crossDomain: true,
//                 success: function(data){
//                     if(data.success){
//                         console.log(data)
//                         _self.index=data;
//                         _self.platform_name=data.data.title;
//                         _self.sys_icon=url_operate+data.data.runAttachment.fullName;
//                     }else{
//                         alert(data.msg);
//                     }
//                 },
//                 error: function(data){
//                     console.log("页面加载失败!");
//                 }
//             });
//         }
//     },
//     created:function() {
//         this.index_ajax();
//     }
// });

var e = "<i class='fa fa-times-circle'></i> "; //表单验证错误的“x”图标
/*$.validator.addMethod("pwd", function(value, element, param){
    //方法中又有三个参数:value:被验证的值， element:当前验证的dom对象，param:参数(多个即是数组)
//      console.log(value + "," + $(element).val() + "," + param );
    return new RegExp(/^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{8,}$/).test(value);
});*/

//  step1填写联系方式
var contact_id=null;
var user_id=null;
$(".step_1 form").validate({
    rules: {
        currPass: {
            required: !0,
            pwd:true
        },
        newPass: {
            required: !0,
            pwd:true
        },
        rePass: {
            equalTo:"#newPass"
        }
    },
    messages: {
        currPass: {
            required: e + "请输入您的原始密码",
            pwd: e + "密码必须由8以上的数字和字母组成"
        },
        newPass: {
            required: e + "请输入您的新密码",
            pwd: e + "密码必须由8以上的数字和字母组成"
        },
        rePass: {
            equalTo: e + "两次密码输入不一致"
        }
    },
    submitHandler: function (form) {
        var $form = $(form),
        data = $form.serialize();
        console.log(data)
        $.ajax({
            url : url_web+"sys/user/register/1",
            type : "get",
            xhrFields: {
                withCredentials: true
            },
            crossDomain: true,
            data : data,
            success : function(data) {
                console.log(data)
                if(data.success){
                    $(".step_1").addClass('hidden');
                    $(".step_2").removeClass('hidden');
                    $(".step-icon:eq(1)").addClass('step-active');
                    contact_id=data.data.id;
                }else{
                    alert(data.msg)
                }
                /*if(data.success){
                    // alert('密码修改成功！')
                    // window.location.href='index.html'
                }else {
                    alert(data.msg)
                }*/
            },
            error : function(){
                alert("请求失败!");
            }
        });
    }
});

var Request=GetRequest();
console.log(Request);
console.log(Request.acode);
if(Request.acode){
    $.ajax({
        url : url_web+"sys/user/checkAcode/"+Request.acode,
        type : "post",
        xhrFields: {
            withCredentials: true
        },
        crossDomain: true,
        data : '',
        success : function(data) {
            console.log(data)
            if(data.success){
                $(".step_1").addClass('hidden');
                $(".step_2").addClass('hidden');
                $(".step_3").removeClass('hidden');
                $(".step-icon:eq(1)").addClass('step-active');
                user_id=data.data;
            }else {
                alert(data.msg)
            }
        },
        error : function(){
            alert("请求失败!");
        }
    });
}
// 重新发送验证邮件
$('.resend').click(function (){
    console.log('22')
    if(contact_id!=null){
        $.ajax({
            url : url_web+"sys/user/register/2",
            type : "get",
            xhrFields: {
                withCredentials: true
            },
            crossDomain: true,
            data : {"registerId":contact_id},
            success : function(data) {
                alert('重新发送成功！')
                console.log(data)
                /*if(data.success){
                    // alert('密码修改成功！')
                    // window.location.href='index.html'
                }else {
                    alert(data.msg)
                }*/
            },
            error : function(){
                alert("请求失败!");
            }
        });
    }
})

//  step3填写公司信息
$(".step_3 form").validate({
    rules: {
        currPass: {
            required: !0,
            pwd:true
        },
        newPass: {
            required: !0,
            pwd:true
        },
        rePass: {
            equalTo:"#newPass"
        }
    },
    messages: {
        currPass: {
            required: e + "请输入您的原始密码",
            pwd: e + "密码必须由8以上的数字和字母组成"
        },
        newPass: {
            required: e + "请输入您的新密码",
            pwd: e + "密码必须由8以上的数字和字母组成"
        },
        rePass: {
            equalTo: e + "两次密码输入不一致"
        }
    },
    submitHandler: function (form) {
        var $form = $(form),
        data = $form.serialize();
        data+="&userId="+user_id;
        console.log(data)
        $.ajax({
            url : url_web+"sys/user/register/3",
            type : "get",
            xhrFields: {
                withCredentials: true
            },
            crossDomain: true,
            data : data,
            success : function(data) {
                console.log(data)
                if(data.success){
                    $(".step_3").addClass('hidden');
                    $(".step_4").removeClass('hidden');
                    $(".step-icon:eq(2)").addClass('step-active');
                }else{
                    alert(data.msg)
                }
            },
            error : function(){
                alert("请求失败!");
            }
        });
    }
});